package test;

import java.util.Arrays;
import java.util.function.Function;

/**
 * @author yuanZhi
 * @since 2021/5/28 14:43
 */
public class CurryAndCompose {
	private static int add(int x, int y, int z) {
		return x + y + z;
	}

	private static <A, B, C, D> Function<A, Function<B, Function<C, D>>> curry(
			TriFunction<A, B, C, D> fn) {
		return a -> b -> c -> fn.apply(a, b, c);
	}

	public static void main(String[] args) {
		Function<Integer, Function<Integer, Function<Integer, Integer>>> newAdd = curry(
				CurryAndCompose::add);
		System.out.println(newAdd.apply(2).apply(3).apply(4));

		String s = "123456.png";
		String substring = s.substring(s.lastIndexOf("."));
		System.out.println(s.substring(0, s.length() - substring.length()));
		System.out.println(substring);


		System.out.println(Arrays.toString("".split(",")));

	}
}
